﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Othello_Game
{
    /// <summary>
    /// A normalize attribute implementing IAttributeNormalizedValues interface.
    /// Returns a score indicating the relative ammont of pieces taken by
    /// the playing player relative to the number of turns played so far.
    /// </summary>
    public class RelativePlayerPiecesNumAttribute : IAttributeNormalizedValues
    {
        public double GetAttributeValues(ActionList actionList)
        {
            double diff = 0.0;
            Score boardScore = actionList.BoardState.GetBoardScore();

            switch (actionList.BoardState.CurrentPlayer)
            {
                case players.PLAYER1:
                    diff = (double) boardScore.BlackPlayer;
                    break;
                case players.PLAYER2:
                    diff = (double) boardScore.WhitePlayer;
                    break;
                default:
                    break;
            }

            int stepsTaken = boardScore.WhitePlayer + boardScore.BlackPlayer;
            diff =  diff / (double) (stepsTaken);
            if (stepsTaken > 36) return diff;
            else return diff / 2.0;
        }
    }
}
